import React, { useState } from 'react'

export default function App () {
  //作用： 提供状态和修改状态的方法
  //参数：代表默认值
  // 返回值：数组[初始化数据，修改数据的方法]
  // const [count, setCount] = useState(0)
  const [count, setCount] = useState({
    name: '张三',
    age: 18
  })
  const handleCick = () => {
    // setCount(count + 1)
    setCount({
      name: count.name = '李四',
      age: count.age + 1
    })
  }
  return (
    <div>
      {/* <h2> 计数器：{count}</h2> */}
      <h2>姓名：{count.name} 计数器：{count.age}</h2>
      <button onClick={handleCick}>+1</button>
    </div>
  )
}

